package examination.WeBank_09_13;

import java.util.*;

/**
 * 数字的最少变换次数
 */
public class Question2 {
    public static void main(String[] args)  {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            long max = in.nextLong();
            long min = in.nextLong();
            if (min > max) {
                long tmp = max;
                max = min;
                min = tmp;
            }
            if (max % min != 0) {
                System.out.println(-1);
            } else {
                long remain = max / min;
                if ((remain & remain - 1) == 0) {
                    int times = 0;
                    while (remain != 1) {
                        if (remain >> 3 > 0) {
                            remain >>= 3;
                        } else if (remain >> 2 > 0) {
                            remain >>= 2;
                        } else if (remain >> 1 > 0) {
                            remain >>= 1;
                        }
                        times++;
                    }
                    System.out.println(times);
                } else {
                    System.out.println(-1);
                }
            }
        }
    }
}